package tool;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
 
/**
 * Created by Administrator on 2017/6/6.
 */
public class RefererTest {
    public static void main(String[] args) throws Exception {
        String url = "https://nj.lianjia.com/ershoufang/103100569075.html";
        HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
        conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon;)");
        conn.setRequestProperty("referer", "http://www.baidu.com");
        
        InputStream is = conn.getInputStream();
        StringBuffer sb = new StringBuffer();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String strLine = "";
        while ((strLine = br.readLine()) != null) {
            sb.append(strLine.trim());
        }
        System.out.println(sb.toString());
    }
}